/*     */ package com.zimbra.cs.account;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.accesscontrol.TargetType;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class Alias
/*     */   extends MailTarget
/*     */ {
/*  38 */   private NamedEntry mTarget = null;
/*  39 */   private boolean mIsDangling = false;
/*     */   
/*     */   public Alias(String name, String id, Map<String, Object> attrs, Provisioning prov) {
/*  42 */     super(name, id, attrs, null, prov);
/*     */   }
/*     */   
/*     */   public Entry.EntryType getEntryType()
/*     */   {
/*  47 */     return Entry.EntryType.ALIAS;
/*     */   }
/*     */   
/*     */ 
/*     */   public NamedEntry getTarget(Provisioning prov)
/*     */   {
/*  53 */     if (this.mIsDangling) {
/*  54 */       return null;
/*     */     }
/*     */     
/*  57 */     if (this.mTarget != null) {
/*  58 */       return this.mTarget;
/*     */     }
/*     */     try {
/*  61 */       this.mTarget = prov.getAliasTarget(this, false);
/*     */     } catch (ServiceException e) {
/*  63 */       ZimbraLog.account.warn("cannot find target " + getId() + " for alias " + getName(), e);
/*     */     }
/*     */     
/*     */ 
/*  67 */     if (this.mTarget == null) {
/*  68 */       this.mIsDangling = true;
/*     */     }
/*  70 */     return this.mTarget;
/*     */   }
/*     */   
/*     */   public String getTargetName(Provisioning prov) throws ServiceException {
/*  74 */     NamedEntry target = getTarget(prov);
/*  75 */     if (target == null)
/*  76 */       return null;
/*  77 */     return target.getName();
/*     */   }
/*     */   
/*     */   public String getTargetUnicodeName(Provisioning prov) throws ServiceException {
/*  81 */     String targetName = getTargetName(prov);
/*  82 */     if (targetName == null)
/*  83 */       return null;
/*  84 */     return IDNUtil.toUnicodeEmail(targetName);
/*     */   }
/*     */   
/*     */   public TargetType getTargetType(Provisioning prov) throws ServiceException {
/*  88 */     NamedEntry target = getTarget(prov);
/*  89 */     if (target == null) {
/*  90 */       return null;
/*     */     }
/*  92 */     if ((target instanceof CalendarResource))
/*  93 */       return TargetType.calresource;
/*  94 */     if ((target instanceof Account))
/*  95 */       return TargetType.account;
/*  96 */     if ((target instanceof DistributionList))
/*  97 */       return TargetType.dl;
/*  98 */     if ((target instanceof DynamicGroup)) {
/*  99 */       return TargetType.group;
/*     */     }
/* 101 */     throw ServiceException.FAILURE("invalid target type for alias " + getName(), null);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/Alias.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */